<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :md="6" :sm="8">
            <a-form-item label="物资分类编码">
              <a-input placeholder="物资分类编码" v-model="queryParam.classifyCode"></a-input>
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="24">
              <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
                <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
                <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 10px;margin-right: 10px">重置</a-button>
              </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- table区域-begin -->
    <div>
      <a-table
        ref="table"
        size="middle"
        :scroll="{x:true}"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange,type:this.selectType}"
        class="j-table-force-nowrap"
        @change="handleTableChange">
      </a-table>
    </div>
  </a-card>
</template>

<script>
  import { JeecgListMixin } from '@lone/lone-vue/src/mixins/JeecgListMixin'
  import MmsMaterialClassifyModal from './modules/MmsMaterialClassifyModal'

  export default {
    name: 'MmsMaterialClassifyListView',
    mixins:[JeecgListMixin],
    components: {
      MmsMaterialClassifyModal
    },
    props:{
      mmsClassifyCode:{
        type:String,
        required:false,
      },
      disabledEmit:{
        type:Boolean,
        required:false,
        default:false
      }
    },
    watch:{
      classifyCode(val){
        this.queryParam.mmsClassifyCode = val
        // this.onClearSelected()
        console.log(val);
        this.loadData(1)
      }
    },
    data () {
      return {
        description: '物资分类管理页面',
        disableMixinCreated:true,
        selectType:'checkbox',
        mmsClassifyCode:'',
        // 表头
        columns: [
          {
            title: '#',
            dataIndex: '',
            key:'rowIndex',
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
          {
            title:'物资分类编码',
            align:"center",
            dataIndex: 'classifyCode'
          },
          {
            title:'物资分类名称',
            align:"center",
            dataIndex: 'classifyName'
          },
          {
            title:'父物资分类编码',
            align:"center",
            dataIndex: 'parentId'
          },
          {
            title:'描述',
            align:"center",
            dataIndex: 'remarks'
          },
          {
            title:'状态',
            align:"center",
            dataIndex: 'delFlag'
          }
        ],
        url: {
          list: "/base/mmsMaterialClassify/list",
          delete: "/base/mmsMaterialClassify/delete",
          deleteBatch: "/base/mmsMaterialClassify/deleteBatch",
          exportXlsUrl: "/base/mmsMaterialClassify/exportXls",
          importExcelUrl: "base/mmsMaterialClassify/importExcel"
        },
        dictOptions:{},
      }
    },
    created() {
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      },
    },
    methods: {
      initDictConfig(){
      },
      handleAdd: function (params) {
        if(this.classifyCode){
          this.$refs.modalForm.add(params);
          this.$refs.modalForm.title = "新增";
          this.$refs.modalForm.disableSubmit = false;
        }else{
          this.$message.warning("请选择左侧物资分类!")
        }
      },
      onSelectChange(selectedRowKeys, selectionRows) {
        this.selectedRowKeys = selectedRowKeys;
        this.selectionRows = selectionRows;
        /*if(this.disabledEmit){
          this.$emit("disabledEmit",this.selectedRowKeys[0])
        }*/
      },
      searchReset() {
        this.queryParam = {}
        this.queryParam.mmsClassifyCode = this.mmsClassifyCode
        this.loadData(1)
      },
    }
  }
</script>
<style scoped lang="less">
  @import '~@assets/less/common.less';
  /deep/ .ant-card-body{
    .table-operator{
      margin-bottom:0px!important;
    }
  }
</style>